//
//  UINavigationController+alpha.m
//  details(个人详情页效果)
//
//  Created by 李松 on 2017/11/9.
//  Copyright © 2017年 李松. All rights reserved.
//

#import "UINavigationController+alpha.h"

@implementation UINavigationController (alpha)

- (void)setNavigationAlpha:(CGFloat)alpha{
    
    //导航栏背景透明度设置
    UIView *barBackgroundView = [[self.navigationBar subviews] objectAtIndex:0];
        
    UIImageView *backgroundImageView = [[barBackgroundView subviews] objectAtIndex:0];
    
    if (self.navigationBar.isTranslucent) {
        if (backgroundImageView != nil && backgroundImageView.image != nil) {
            barBackgroundView.alpha = alpha;
        }else{
            UIView *backgroundEffectView = [[barBackgroundView subviews] objectAtIndex:1];// UIVisualEffectView
            if (backgroundEffectView != nil) {
                backgroundEffectView.alpha = alpha;
            }
        }
    }else {
        barBackgroundView.alpha = alpha;
    }
    
    // 对导航栏下面那条线做处理
    self.navigationBar.clipsToBounds = YES;
    
}

@end
